import request from '@/utils/request';

/**
 * 品牌管理API
 */

// 获取品牌列表
export function getBrandList(params = {}) {
  return request({
    url: '/api/config/brand-config',
    method: 'get',
    params
  });
}

// 获取品牌详情
export function getBrandDetail(id) {
  return request({
    url: `/api/config/brand-config/${id}`,
    method: 'get'
  });
}

// 创建品牌
export function createBrand(data) {
  return request({
    url: '/api/config/brand-config',
    method: 'post',
    data
  });
}

// 更新品牌
export function updateBrand(id, data) {
  return request({
    url: `/api/config/brand-config/${id}`,
    method: 'put',
    data
  });
}

// 删除品牌
export function deleteBrand(id) {
  return request({
    url: `/api/config/brand-config/${id}`,
    method: 'delete'
  });
}

// 批量创建品牌
export function bulkCreateBrands(data) {
  return request({
    url: '/api/config/brand-config/bulk',
    method: 'post',
    data
  });
}

// 批量更新品牌状态
export function bulkUpdateBrandStatus(data) {
  return request({
    url: '/api/config/brand-config/bulk/status',
    method: 'put',
    data
  });
}

/**
 * 商品名称管理API
 */

// 获取商品名称列表
export function getProductNameList(params = {}) {
  return request({
    url: '/api/config/product-names',
    method: 'get',
    params
  });
}

// 获取商品名称详情
export function getProductNameDetail(id) {
  return request({
    url: `/api/config/product-names/${id}`,
    method: 'get'
  });
}

// 创建商品名称
export function createProductName(data) {
  return request({
    url: '/api/config/product-names',
    method: 'post',
    data
  });
}

// 更新商品名称
export function updateProductName(id, data) {
  return request({
    url: `/api/config/product-names/${id}`,
    method: 'put',
    data
  });
}

// 删除商品名称
export function deleteProductName(id) {
  return request({
    url: `/api/config/product-names/${id}`,
    method: 'delete'
  });
}

// 批量创建商品名称
export function bulkCreateProductNames(data) {
  return request({
    url: '/api/config/product-names/bulk',
    method: 'post',
    data
  });
}

// 批量更新商品名称状态
export function bulkUpdateProductNameStatus(data) {
  return request({
    url: '/api/config/product-names/bulk/status',
    method: 'put',
    data
  });
}

/**
 * 营销词管理API
 */

// 获取营销词列表
export function getMarketingWordList(params = {}) {
  return request({
    url: '/api/config/marketing-words',
    method: 'get',
    params
  });
}

// 获取营销词详情
export function getMarketingWordDetail(id) {
  return request({
    url: `/api/config/marketing-words/${id}`,
    method: 'get'
  });
}

// 创建营销词
export function createMarketingWord(data) {
  return request({
    url: '/api/config/marketing-words',
    method: 'post',
    data
  });
}

// 更新营销词
export function updateMarketingWord(id, data) {
  return request({
    url: `/api/config/marketing-words/${id}`,
    method: 'put',
    data
  });
}

// 删除营销词
export function deleteMarketingWord(id) {
  return request({
    url: `/api/config/marketing-words/${id}`,
    method: 'delete'
  });
}

// 批量创建营销词
export function bulkCreateMarketingWords(data) {
  return request({
    url: '/api/config/marketing-words/bulk',
    method: 'post',
    data
  });
}

// 批量更新营销词状态
export function bulkUpdateMarketingWordStatus(data) {
  return request({
    url: '/api/config/marketing-words/bulk/status',
    method: 'put',
    data
  });
}

/**
 * 单位管理API
 */

// 获取单位列表
export function getUnitList(params = {}) {
  return request({
    url: '/api/config/units',
    method: 'get',
    params
  });
}

// 获取单位详情
export function getUnitDetail(id) {
  return request({
    url: `/api/config/units/${id}`,
    method: 'get'
  });
}

// 创建单位
export function createUnit(data) {
  return request({
    url: '/api/config/units',
    method: 'post',
    data
  });
}

// 更新单位
export function updateUnit(id, data) {
  return request({
    url: `/api/config/units/${id}`,
    method: 'put',
    data
  });
}

// 删除单位
export function deleteUnit(id) {
  return request({
    url: `/api/config/units/${id}`,
    method: 'delete'
  });
}

// 批量创建单位
export function bulkCreateUnits(data) {
  return request({
    url: '/api/config/units/bulk',
    method: 'post',
    data
  });
}

// 批量更新单位状态
export function bulkUpdateUnitStatus(data) {
  return request({
    url: '/api/config/units/bulk/status',
    method: 'put',
    data
  });
}

/**
 * 系统配置API
 */

// 获取系统配置列表
export function getSystemConfigList(params = {}) {
  return request({
    url: '/api/config/system',
    method: 'get',
    params
  });
}

// 获取系统配置详情
export function getSystemConfigDetail(id) {
  return request({
    url: `/api/config/system/${id}`,
    method: 'get'
  });
}

// 创建系统配置
export function createSystemConfig(data) {
  return request({
    url: '/api/config/system',
    method: 'post',
    data
  });
}

// 更新系统配置
export function updateSystemConfig(id, data) {
  return request({
    url: `/api/config/system/${id}`,
    method: 'put',
    data
  });
}

// 批量更新系统配置
export function bulkUpdateSystemConfig(data) {
  return request({
    url: '/api/config/system/bulk',
    method: 'put',
    data
  });
}

// 刷新配置缓存
export function refreshConfigCache() {
  return request({
    url: '/api/config/refresh',
    method: 'post'
  });
}

/**
 * 单位转换管理API
 */

// 获取单位转换列表
export function getUnitConversionList(params = {}) {
  return request({
    url: '/api/config/unit-conversions',
    method: 'get',
    params
  });
}

// 创建单位转换
export function createUnitConversion(data) {
  return request({
    url: '/api/config/unit-conversions',
    method: 'post',
    data
  });
}

// 更新单位转换
export function updateUnitConversion(id, data) {
  return request({
    url: `/api/config/unit-conversions/${id}`,
    method: 'put',
    data
  });
}

// 删除单位转换
export function deleteUnitConversion(id) {
  return request({
    url: `/api/config/unit-conversions/${id}`,
    method: 'delete'
  });
}

// 删除单个转换规则
export function deleteConversionRule(id) {
  return request({
    url: `/api/config/unit-conversion-rule/${id}`,
    method: 'delete'
  });
} 